package flc.ast.adapter;

import android.graphics.Color;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.stark.cartoonavatarmaker.lib.core.AvatarTemplateCategory;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.bean.StkResBean;

public class TypeAdapter extends StkProviderMultiAdapter<AvatarTemplateCategory> {

    public TypeAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new TypeProvider());
    }

    private int selPosition;

    public void setSelPosition(int selPosition) {
        this.selPosition = selPosition;
    }

    private class TypeProvider extends BaseItemProvider<AvatarTemplateCategory> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_type;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, AvatarTemplateCategory bean) {
            baseViewHolder.setText(R.id.tvTypeItemName, bean.name);
            if (baseViewHolder.getBindingAdapterPosition() == selPosition) {
                baseViewHolder.setTextColor(R.id.tvTypeItemName, Color.parseColor("#FFFFFF"));
            } else {
                baseViewHolder.setTextColor(R.id.tvTypeItemName, Color.parseColor("#B04B77"));
            }
        }
    }

}
